﻿<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
%>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="copyright" content="" />
<meta name="keywords" content="" />
<meta name="description" content="" />
<title>活动管理</title>
<link href="<%=path%>/favicon.ico" rel="shortcut icon">
<link href="https://cdn.jsdelivr.net/gh/bootcdn/BootCDN/ajax/libs/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" type="text/css"
	href="<%=path%>/css/marketing/public.css" />
<link rel="stylesheet" type="text/css"
	href="<%=path%>/css/marketing/activity.css" />
<link rel="stylesheet" type="text/css"
	href="<%=path%>/css/marketing/style_list.css" />
	
<link href="<%=path%>/hplus/css/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
<link href="<%=path%>/hplus/css/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
<link href="<%=path%>/hplus/css/plugins/iCheck/custom.css" rel="stylesheet">
<link href="<%=path%>/hplus/css/animate.min.css" rel="stylesheet">
<link href="<%=path%>/hplus/css/style.min862f.css?v=4.1.0" rel="stylesheet">	
<link href="<%=path%>/css/marketing/s_style.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="<%=path%>/hplus/js/plugins/sweetalert/sweetalert2.min.css">
<style>
.x_basics .x_basics_list li span {
	width: 10%;
}

input[type='date']::-webkit-inner-spin-button {
	display: none;
}

.x_basics_list li span {
    color: #666;
    display: inline-block;
    float: left;
    margin-right: 10px;
    text-align: right;
}
.checkbox-inline img {
    margin: 10px;
}
.x_basics_list .form li input {
    height: 40px;
    line-height: 40px;
    padding-left: 6px;
    margin:0 10px;
}
.x_basics_list li input, .x_basics_list li select, .x_basics_list li textarea {
    border: 1px solid #ddd;
    border-radius: 3px;
    /* margin-left: 4px; */
    padding-left: 8px;
}
.radio-inline, .checkbox-inline {
    display: inline-block;
    padding-left: 10px;
    margin-bottom: 0;
    font-weight: normal;
    vertical-align: middle;
    cursor: pointer;
}
.x_basics_list li span {
    width: 100px;
}
#inputfile {
    height: 100px;
    margin-left: 90px;
    opacity: 0;
    position: absolute;
    width: 100px;
    z-index: 99;
}
.form b{color:#ed5565;padding:3px 6px;vertical-align: middle; line-height: 19px;}
.x_button_r {
    margin: 30px 100px 20px 100px;
}
.x_button_r a {
    margin-left: 40px;
}
.table_tu{ border: 3px solid  #04a9f5; border-radius: 6px; filter:alpha(opacity=50); margin-right: 100px; margin-top: 11%; padding:20px; background: #fff;}
.kkkk h1 i {
    background: #999;
}
.kkkk h1{    font-size: 15px;}

.kkkk h1 p {
    background: #fafafa;
}
i {
    font-style: initial;
}
.kkkk h1 i {
    width: 190px;
    height: 1px;
    display: inline-block;
    position: absolute;
    margin-top: 21px;
    margin-left: 50px;
}
    .kkkk h1 p {
    line-height: 40px;
    text-align: center;
    position: absolute;
    z-index: 3;
    width: 140px;
    margin-left: 60px;
    height: 40px;
margin-left: 75px;
    font-weight: bold;}
    .color_png{ position: absolute;
    z-index: 99;left: 550px;}
</style>
</head>
<body class="gray-bg">

	<div class="wrapper wrapper-content animated fadeInRight">
	<div class="container-fluid">
		<div class="row">      
		 <div class="col-md-12">
                   <div class="x_progress s_big">
		            <div class="s_line">
		                <div class="s_progress_bar s_current" role="progressbar"
	                     aria-valuenow="60" aria-valuemin="0" aria-valuemax="100">
	                    <span class="sr-only_1">1</span>
	                    <p class="x_color_bz">选择模板</p >
	                </div>
	                <div class="s_progress_bar s_current" role="progressbar"
	                     aria-valuenow="60" aria-valuemin="0" aria-valuemax="100">
	                    <span class="sr-only_2">2</span>
	                    <p class="x_color_bz">编辑内容</p >
	                </div>
	                <div class="s_progress_bar s_current" role="progressbar"
	                     aria-valuenow="60" aria-valuemin="0" aria-valuemax="100">
	                    <span class="sr-only_3">3</span>
	                    <p class="x_color_bz">成功提示页</p >
	                </div>
	                <div class="s_progress_bar s_current" role="progressbar"
	                     aria-valuenow="60" aria-valuemin="0" aria-valuemax="100">
	                    <span class="sr-only_3">4</span>
	                    <p class="x_color_bz">分享设置</p >
	                </div>
	                <div class="s_progress_bar" role="progressbar"
	                     aria-valuenow="60" aria-valuemin="0" aria-valuemax="100">
	                    <span class="sr-only_4">5</span>
	                    <p class="x_color_bz">活动预览</p >
	                </div>
	                <div class="s_progress_bar" role="progressbar"
	                     aria-valuenow="60" aria-valuemin="0" aria-valuemax="100">
	                    <span class="sr-only_5">6</span>
	                    <p class="x_color_bz">分享</p >
	                </div>
		            </div>
		          </div>   
		          </div>
            <div class="col-md-12">
                <div class="x_template ">
                    <!--内容左侧-->
                    <div class="x_basics_list x_basics x_floatl x_w ">
                        <p style="padding: 20px 20px 0 20px; text-align: right;text-decoration:underline"><a id="again_chose_model" href="<%=path%>/view/ui/chooseActivityTemplate"
							style="background: none; color: #03a9f4;">重新选择模板</a></p>
                        <div style="margin:20px; border:1px solid #d2d2d2;">
                            <ul class="form" style="padding:8px; font-size: 14px;" >
                            <li><span style="left:10px;margin-left: -15px;"><b >*</b>活动名称</span><input type="text" class="input-medium" id="bm_ac3" maxlength="25" onblur="checkLength(this)"/></li>                        
                            <li ><span style="padding:12px 0;margin-left: -28px;"><b >*</b>有效期</span>
                                <label class="checkbox-inline i-checks x_radio_li5" style="padding:12px 0;">
                                    <img src="<%=path%>/images/marketing/img_radio.png" class="x_radio_pic5" _id="9" />分享后&nbsp;
                                </label>
                                <input type="text" id="bm_tian" style="ime-mode:disabled;" onkeyup="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}" onafterpaste="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'0')}else{this.value=this.value.replace(/\D/g,'')}" maxlength="2"/>天有效 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</br>
                                <span style="padding:12px 0;"><b ></b>&nbsp;</span>
                                <label class="checkbox-inline i-checks x_radio_li6" style="padding:12px 0;margin-left: -28px;">
                                    <img id="img_time" src="<%=path%>/images/marketing/img_radio_n.png" class="x_radio_pic6" _id="11" />
                                </label>
                                 <!-- <select class="col-lg-2">
                                    <option>年-月-日</option>
                                    <option>2</option>
                                    <option>3</option>
                                    <option>4</option>
                                    <option>5</option>
                                </select>
                                &nbsp;至&nbsp;
                                <select class="col-lg-2 ">
                                    <option>年-月-日</option>
                                    <option>2</option>
                                    <option>3</option>
                                    <option>4</option>
                                    <option>5</option>
                                </select>&nbsp;&nbsp;有效  -->
                                <input type="date" id="bm_qi" disabled="disabled" style="vertical-align: middle;"> 至 <input type="date" id="bm_zui" disabled="disabled">
                                </br>  
                                <span style="padding:12px 0;"><b ></b>&nbsp;</span>
                                <label class="checkbox-inline i-checks x_radio_li7" style="padding:12px 0;margin-left: -138px;">
                                    <img src="<%=path%>/images/marketing/img_radio_n.png" class="x_radio_pic7" _id="9" />不限&nbsp;
                                </label>
                                
                            </li>
                            <li>
                                <label class="checkbox-inline i-checks s_fx_li12" style="width:110px;">
                                    <img src="<%=path%>/images/marketing/s_check_no.png" class="s_fk_pic12" _id="23" />参与名额&nbsp;
                                </label>
                            	<input type="text"  id="bm_ling" style="ime-mode:disabled;" onkeypress="keyPress()" maxlength="7">&nbsp;(若不选择将不限制参与名额）</li>
                            <li>
                                <label class="checkbox-inline i-checks s_fx_li13" style="padding:12px 12px;width:110px;">
                                    <img src="<%=path%>/images/marketing/s_check_no.png" class="s_fk_pic13" _id="25" />到期前&nbsp;
                                </label>
                            	<input type="text"  id="bm_ting" style="ime-mode:disabled;" onkeyup="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}" onafterpaste="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'0')}else{this.value=this.value.replace(/\D/g,'')}" maxlength="2">&nbsp;天提醒短信 (有手机号才提醒）</li>
                             <li>
                                <label class="checkbox-inline i-checks s_fx_li13" style="padding:12px 12px;width:110px;">
                                </label>
                            	<textarea  id="expireReminderContent" placeholder="提醒内容" name="comment"  required="" aria-required="true" style="height:80px;width:250px;margin-left:10px" id="bm_ac3" maxlength="45" onblur="checkLength(this)"></textarea>
		                        <img id="hint" src="<%=path%>/images/marketing/help.png" />
		                        <a class="alert alert-success" hidden="">
		                            	尾部会默认拼接：有效期还有N天。
		                        </a>
                            </li>	
                        </ul>
                    </div>
                    <!--内容左侧end-->
                    <div style="margin:20px;background-color: #fafafa;">
                        <ul class="form" style="padding:8px; font-size: 14px; width:61%; float:left;">
                        <li><span><b >*</b>活动标题</span><input type="text" class="input-medium" style="width:390px;" id="bm_bti" maxlength="25" onblur="checkLength(this)"/>
                            <p style="color: #bdbdbd;"><span><b ></b>&nbsp;</span>&nbsp;&nbsp;建议以朋友亲切的口吻;建议以14字以内</p>
                        </li>
                        <li><span><b >*</b>活动文案</span><input type="text"  class="input-medium"  style="width:390px;" id="bm_tu" maxlength="50" onblur="checkLength(this)"/>
                            <p style="color: #bdbdbd;"><span><b ></b>&nbsp;</span>&nbsp;&nbsp;建议以朋友亲切的口吻;建议以50字以内</p>
                        </li>
                            <!-- <li><span>示例</span> <img src="<%=path%>/images/marketing/aaa.png" /></li>
                            <li><span>标题</span><input type="text" class="input-medium" /></li>
                            -->
                            <li><span><b >*</b>上传图片</span>
                            	<div class="x_img_sc">
									<img id="share_pic" style="width: 100px; height: 100px"src="<%=path%>/images/marketing/img_p.png">
								</div> 
								<form  id='share_image' enctype='multipart/form-data'>
								    <input type="file" accept="image/gif,image/jpeg,image/x-png" id="inputfile" onchange="fileloadon()" name="filepath"
								    style="filter: alpha(opacity = 50); -moz-opacity: 0.5; -khtml-opacity: 0.5; opacity: 0.0; position: absolute; z-index: 99;">
								    <p style="line-height:80px;color: #bdbdbd;"> &nbsp;&nbsp;(上传图片要求：尺寸为120×120像素，大小10K左右)</p>
								</form>
                                <div class="clear-shadow"></div>
                            </li>
                        </ul>

                        <div style="width:39%;float:left;  margin-top: 40px;" class="kkkk">
                            <h1 ><p>分享后显示效果</p><i></i></h1>
                             <div class="table_tu">
                                <b class="text-center" style="font-size: 18px; color:#333333;" id="ep_title">毕业聚餐好去处  相约“眉州东坡”</b>
                                <div class="row mar-b-50" style="margin-top:20px;">
                                <div  class="col-sm-8 col-sm-8  wow fadeInUp" id="ep_text">毕业聚餐好去处   相约“眉州东坡”毕业聚餐好去处   相约“眉州东坡”毕</div>
                                <div class="col-sm-4 col-sm-4 text-center wow fadeInUp"><img id="ep_pic" src="<%=path%>/images/marketing/annex_img.png" style="width:80px;"></div>
                                                               </div>
                             </div>
                        </div>
                        <div class="color_png" style="margin-top:38px;"><img src="<%=path%>/images/marketing/ls_color.png"></div>
                        <div class="color_png" style="margin-top:135px;"><img src="<%=path%>/images/marketing/hs_color.png"></div>
                        <div class="color_png" style="margin-top:200px;left: 620px;"><img src="<%=path%>/images/marketing/zs_color.png"></div>

                        <div class="clear-shadow"></div>
                        </div>
                        <div class="clear-shadow"></div>
                        <div>
                        <ul>
                         <li>                                
                                <p style="margin-left:30px;"><img src="<%=path%>/images/marketing/s_check.png" class="s_fk_pic1" _id="1" />&nbsp;允许收录模板库</p>
                            </li>                         
                            <li>
                                <div class="x_button_r">
                                    <a class=" x_button_l k_btn_one" style="color: #03a9f4;" href="javascript:;">返回上级</a> 
                                    <a class="x_button " style="float:right;" href="javascript:;" id="bm_yulan">预览</a>
                                    <a class="x_button " style="float:right;" href="javascript:;">保存并分享</a> 
                                    <a class="x_button_y " style="float:right;" href="javascript:;">保存</a> 
                                </div>
                            </li>   
                        </ul>  
                    </div>
                    </div>
                    
                </div>
            </div>
        </div>
		
	</div>
	</div>
	<!-- 添加账号弹框 -->
	<div class="x_popup">
		<div class="issue x_xk_issue">
			<span><img src="<%=path%>/images/marketing/close.png" /></span>
			<h4>扫一扫 立刻分享</h4>
			<p>
				<img src="<%=path%>/images/marketing/code.jpg" />
			</p>
		</div>
	</div>
	<!-- 添加账号弹框end -->
	
	 <div class="s_popup_delect2">
        <div class="s_consum">
            <p id="dialog_title"><img src="<%=path%>/images/marketing/s_tick.png" /> 活动启用成功</p>
        </div>
    </div>
    
    	<!-- 删除活动弹框 -->
	<div class="s_popup_delect">
		<div class="issue_delect">
			<span><img src="<%=path%>/images/marketing/close.png" /></span>
			<h4>
				<img src="<%=path%>/images/marketing/s_tick.png" /> 保存成功
			</h4>
			<p>是否立即分享？</p>
			<ol class="fix">
				<li onclick="javascript:window.location.href='<%=path%>/view/ui/activityHome';"><a href="<%=path%>/view/ui/activityHome" class="s_cancel">否</a></li>
				<li onclick="javascript:intentShare();"><a href="javascript:intentShare();">是</a></li>
			</ol>
		</div>
	</div>
    
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/bootcdn/BootCDN/ajax/libs/bootstrap/3.3.7/js/bootstrap.min.js"></script>
	<script>
        $('.J_x_box').click(function () {
        $('.x_popup').show();
        $('.issue').show();
	    });
	    $('.x_popup .issue span').click(function () {
	        $('.x_popup').hide();
	        $('.issue').hide();
	    });
	  //参与名额
	    $('.s_fx_li12').click(function () {
	        var id = $(this).find('img').attr('_id');
	        if (id == 23) {
	            $('.s_fk_pic12').attr('src', '<%=path%>/images/marketing/s_check_no.png');
	            $(this).find('img').attr('_id', '24');
	            $("#bm_ling").attr("disabled","disabled");
	            couponNumTag=false;
	            console.log("---------11111111111111>");
	        } else {
	            $('.s_fk_pic12').attr('src', '<%=path%>/images/marketing/s_check.png');
	            $(this).find('img').attr('_id', '23');
	            $("#bm_ling").removeAttr("disabled");
	            couponNumTag=true;
	            console.log("--------->222222222");
	        }
	    });
	  
	    $('.s_fx_li13').click(function () {
	        var id = $(this).find('img').attr('_id');
	        if (id == 25) {
	            $('.s_fk_pic13').attr('src', '<%=path%>/images/marketing/s_check_no.png');
	            $(this).find('img').attr('_id', '26');
	            $("#bm_ting").attr("disabled","disabled");
	            expire_chose_Tag=false;
	        } else {
	            $('.s_fk_pic13').attr('src', '<%=path%>/images/marketing/s_check.png');
	            $(this).find('img').attr('_id', '25');
	            $("#bm_ting").removeAttr("disabled");
	            expire_chose_Tag=true;
	        }
	    });
	    //分享
	    $('.x_radio_li5').click(function () {
			$(this).find('img').prop('src', '<%=path%>/images/marketing/img_radio.png');
			$("#bm_tian").removeAttr("disabled");
	        $('.x_radio_pic6').prop('src', '<%=path%>/images/marketing/img_radio_n.png');
	        $("#bm_qi").attr("disabled","disabled");
	     	$("#bm_zui").attr("disabled","disabled");
	     	$('.x_radio_pic7').prop('src', '<%=path%>/images/marketing/img_radio_n.png');
			validityTag3=false;
			validityTag1=true;
			validityTag2=false;
	    });
	    //选择时间
	    $('.x_radio_li6').click(function () {
			$(this).find('img').prop('src', '<%=path%>/images/marketing/img_radio.png');
			$("#bm_qi").removeAttr("disabled");
	      	$("#bm_zui").removeAttr("disabled");
			$('.x_radio_pic5').prop('src', '<%=path%>/images/marketing/img_radio_n.png');
			$("#bm_tian").attr("disabled","disabled");
			$('.x_radio_pic7').prop('src', '<%=path%>/images/marketing/img_radio_n.png');
			validityTag3=false;
			validityTag1=false;
			validityTag2=true;
	    });
	  //不限
	    $('.x_radio_li7').click(function () {
	    	console.log("buxian--->");
			$(this).find('img').prop('src', '<%=path%>/images/marketing/img_radio.png');
			$("#bm_tian").removeAttr("disabled");
	        $('.x_radio_pic6').prop('src', '<%=path%>/images/marketing/img_radio_n.png');
	        $("#bm_qi").attr("disabled","disabled");
	     	$("#bm_zui").attr("disabled","disabled");
	     	$('.x_radio_pic5').prop('src', '<%=path%>/images/marketing/img_radio_n.png');
			$("#bm_tian").attr("disabled","disabled");
			validityTag3=true;
			validityTag1=false;
			validityTag2=false;
	    });
	  //  $("#id").attr("disabled","disabled");
	  
	    //允许收录模板库
	    $('.x_radio_li9').click(function () {
	        var id = $(this).find('img').attr('_id');
	        if (id == 18) {
	            $('.s_fk_pic1').attr('src', '<%=path%>/images/marketing/s_check_no.png');
	            $(this).find('img').attr('_id', '19');
	        } else {
	            $('.s_fk_pic1').attr('src', '<%=path%>/images/marketing/s_check.png');
	            $(this).find('img').attr('_id', '18');
	        }
	    });
	    
	    $("#bm_bti").bind("input propertychange",function(){
	    	var titleVal = $("#bm_bti").val();
	    	$("#ep_title").text(titleVal);
	    });
	    
	    $("#bm_tu").bind("input propertychange",function(){
	    	var textVal = $("#bm_tu").val();
	    	$("#ep_text").text(textVal);
	    });
	    
		 $('.k_delect_btn').click(function(){
	         $('.s_popup_delect,.issue_delect').show();
	     });

	     $('.s_cancel,.issue_delect span').click(function(){
	         $('.s_popup_delect,.issue_delect').hide();
	     });
    
    </script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
    <script src="https://cdn.jsdelivr.net/gh/bootcdn/BootCDN/ajax/libs/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>
	<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.form/4.2.2/jquery.form.min.js"></script>
	<script type="text/javascript" src="<%=path%>/js/marketing/lengthlimit.js"></script>
	<script src="<%=path%>/hplus/js/plugins/sweetalert/sweetalert2.min.js"></script>
	<script type="text/javascript" src="<%=path%>/js/marketing/dialog.js"></script>
	<script type="text/javascript" src="<%=path%>/js/dateUtils.js"></script>
	<script type="text/javascript">
       //保存
       $('.x_button_y').click(function(){
    	   saveAc();
       });
       //预览
       $('.x_button').click(function(){
    	   save_tag=true;
    	   saveAc();
    	   
    	}); 
       //返回上一页
       $('.x_button_l').click(function(){
    	   if(tag=="defined_text"){
       		window.location.href = "<%=path%>/view/ui/createActivitySuccessPage?activityId="+activity_id+"&type=edit";
    	   }else if(tag=="defined_pic"){
    		   window.location.href = "<%=path%>/view/ui/createActivitySuccessPage?activityId="+activity_id+"&type=edit";
       	}else{
       		window.location.href = "<%=path%>/view/ui/createActivity2?type=edit&&activity_id="+activity_id;
       	}
       });
       //重新选模板
  /*       $('#again_chose_model').click(function(){
    	   window.history.back(); 
       }); */
       
 	   var access_token=$.cookie('access_token');
	   var cid=$.cookie('cid');
	   var uid=$.cookie('uid');
       var share_title;
       var effective_day;
       var share_pic;
       var tag_defined;
       var share_content;
       var coupon_number;
       var activity_title;
       var activity_id=1;
       var coupon_expire_day;
       var start_time;
       var last_time;
       var web_url;
       var tag;
       var type;
       var expire_chose_Tag=true;
       var couponNumTag=false;//参与名额标记
       var save_tag=false;
       var validityTag1=false;
       var validityTag2=true;
       var validityTag3=false;
       var expireReminderContent=""//提醒内容
       $(function(){
    	   $('#hint').mouseover(function(){
               $('.alert').show();
           });
           $('#hint').mouseout(function(){
               $('.alert').hide();
           });

    	   //获取活动id
    	   activity_id=getQueryString("activity_id");
    	   if(StringEmpty(activity_id)){
    		   getActivityInfo(activity_id);
    	   }
       });
       
       function saveAc(){
        	//活动名称
        	 activity_title= $('#bm_ac3').val();
        	//有效天数
        	effective_day = document.getElementById("bm_tian").value
        	//起始时间
        	 start_time = $('#bm_qi').val();
        	//最后时间
        	 last_time = $('#bm_zui').val();
        	//累计领取数量       	
        	 coupon_number= $('#bm_ling').val();
        	//多少天短信提醒
        	 coupon_expire_day= $('#bm_ting').val();
        	/* //标签
        	tag_defined = $('#bm_biao').val(); */
        	//示例
        	/* var last_time = $('#bm_tnei').val(); */
        	//标题
            share_title = $('#bm_bti').val();
        	//文案
        	share_content = $('#bm_tu').val();
        	//到期提醒内容
        	expireReminderContent=$('#expireReminderContent').val();
        	//图片
        	if(StringEmpty(tag_defined)&&!isNaN(tag_defined)){
        		errorDialog("标签不能只输入数字");
        	    save_tag=false;
        		return ;
        	}
        	if(StringEmpty(share_title)&&!isNaN(share_title)){
        		errorDialog("分享标题不能只输入数字");
        		save_tag=false;
        		return ;
        	}
        	if(StringEmpty(share_content)&&!isNaN(share_content)){
        		errorDialog("分享内容不能只输入数字");
        		save_tag=false;
        		return ;
        	}
        	if(!StringEmpty(share_pic)){
        		errorDialog("请上传分享图片");
        		return ;
        	}
        	
        	
        	if(!couponNumTag)
        		coupon_number=1000000;
        	
        	if(validityTag1){
        		if(!StringEmpty(effective_day)){
        			errorDialog("请输入分享后有效天数");
        			save_tag=false;
        			return ;
        		}
        		
        		if(!isNumber(effective_day)){
    				errorDialog("活动有效天数只能输入数字");
    				save_tag=false;
    				return ;
    				
    			}else if(effective_day>60){
    				errorDialog("活动有效期最多为60天");
    				save_tag=false;
    				return ;
    			}
        		start_time="";
        		last_time="";
        	}else if(validityTag2){
        		effective_day="0";
        		if(!StringEmpty(start_time)){
        			save_tag=false;
            		errorDialog("请选择活动开始时间");
            		return ;
        		}
        		
        		if(!StringEmpty(last_time)){
        			save_tag=false;
            		errorDialog("请选择活动结束时间");
            		return ;
        		}
        		
        		if(start_time>last_time){
        			save_tag=false;
            		errorDialog("开始时间不能大于结束时间");
            		return ;
        		}
        		
        	}else if(validityTag3){
        		console.log("---->buxian");
        		start_time="";
        		last_time="";
        		effective_day=0;
        	}
        	if(StringEmpty(activity_title)&&StringEmpty(share_title)&&StringEmpty(share_content))
        	{
        		if(expire_chose_Tag){
        			if(!StringEmpty(coupon_expire_day)){
        				errorDialog("请输入到期提醒天数");
        				save_tag=false;
                		return ;
        			}
        			
        			else if(!isNumber(coupon_expire_day)){
                		errorDialog("到期提醒天数只能输入数字");
                		save_tag=false;
                		return ;
                	}
                	else if(coupon_expire_day>10){
                		errorDialog("最多提前10天提醒");
                		save_tag=false;
                		return ;
                	}else if(!StringEmpty(expireReminderContent)){
                		errorDialog("请输入优惠券到期的提醒内容");
                		save_tag=false;
                		return ;
                	}
        		}else{
        			coupon_expire_day="";
        		}
        		save();
        		
        	}else if(!StringEmpty(activity_title)){
        		save_tag=false;
        		errorDialog("请输入活动标题");
        	}else if(!StringEmpty(share_title)){
        		save_tag=false;
        		errorDialog("请输入分享标题");
        	}else if(!StringEmpty(share_content)){
        		save_tag=false;
        		errorDialog("请输入分享内容");
        	}else{
        		console.log("failure");
        	}
        	
        	
        }
        //获取活动信息
        function getActivityInfo(activity_id) {
			var url="<%=path%>/activity/ajaxActivityDetail";
			$.post(url, {
				"id" : activity_id,
			}, function(data) {
				
				if (data.status == 200&&data.data!=undefined) {
					initView(data.data);
				} else {
				}
			});
		}
        
        //保存
        function save() {
        	var url = "<%=path%>/activity/ajaxCreateShare";
			$.post(url, {
				"access_token" : access_token,
				"uid" : uid,
				"id" : activity_id,
				"effectiveDay" : effective_day,
				"couponNumber" : coupon_number,
				"tagDefined" : tag_defined,
				"title" : share_title,
				"content" : share_content,
				"pic" : share_pic,
				"couponExpireDay" : coupon_expire_day,
				"status":1,
				"headPic":share_pic,
				"name":activity_title,
				"expireReminderContent":expireReminderContent,
				"startTimeStr" : start_time,
				"endTimeStr" : last_time,
			}, function(data) {
				
				if (data.status == 200) {
					if(save_tag){
						intentShare();
			    	   }else{
			    		   $('.s_popup_delect,.issue_delect').show();
			    	   }
				} else {
					errorDialog("保存失败");
				}
			});
		}
		//初始化页面
		function initView(data) {
			//活动标题
			if (StringEmpty(data.name))
				document.getElementById('bm_ac3').value = data.name;
			if (StringEmpty(data.effectiveDay))
				document.getElementById('bm_tian').value = data.effectiveDay;
			if (StringEmpty(data.startTime)){
				document.getElementById('bm_qi').value = formatDateTimeYMD(Date.parse(data.startTime));
			}
			if (StringEmpty(data.endTime))
				document.getElementById('bm_zui').value = formatDateTimeYMD(Date.parse(data.endTime));
			if (StringEmpty(data.couponNumber)&&data.couponNumber!=1000000){
				document.getElementById('bm_ling').value = data.couponNumber;
			}else{
				console.log("------------sssss---->ssssssssss");
				$('.s_fk_pic12').prop('src', '<%=path%>/images/marketing/s_check_no.png');
				$("#bm_ling").attr("disabled","disabled");
				$(".s_fk_pic12").attr('_id',"24");
			}
				
			if (StringEmpty(data.title)){
				document.getElementById('bm_bti').value = data.title;
				$("#ep_title").text(data.title);
			}
			
			if (StringEmpty(data.content)){
				document.getElementById('bm_tu').value = data.content;
				$("#ep_text").text(data.content);
			}
			if (StringEmpty(data.couponExpireDay)&&data.couponExpireDay!=0){
				document.getElementById('bm_ting').value = data.couponExpireDay;
				expire_chose_Tag=true;
			}else{
				$("#bm_ting").attr("disabled","disabled");
				$(".s_fk_pic13").attr('_id',"26");
				expire_chose_Tag=false;
			}
			console.log(expire_chose_Tag);
			/* if (StringEmpty(data.tag_defined))
				document.getElementById('bm_biao').value = data.tag_defined; */
			if(StringEmpty(data.pic)){
				share_pic=data.pic;
				document.getElementById("share_pic").src =data.pic ; 
				$("#ep_pic").prop('src', data.pic);
			}
			web_url=data.webUrl;
			tag=data.activityType;
			
			if(StringEmpty(data.expireReminderContent)){
				$('#expireReminderContent').val(data.expireReminderContent);
			}
			
			if(data.effectiveDay!=0){
				$("#img_share").prop('src', '<%=path%>/images/marketing/img_radio.png');
				$("#bm_tian").removeAttr("disabled");
		        $('.x_radio_pic6').prop('src', '<%=path%>/images/marketing/img_radio_n.png');
		        $("#bm_qi").attr("disabled","disabled");
		     	$("#bm_zui").attr("disabled","disabled");
		     	validityTag3=false;
				validityTag1=true;
				validityTag2=false;
			}else if(StringEmpty(data.startTime)&&StringEmpty(data.endTime)){
				$("#img_time").prop('src', '<%=path%>/images/marketing/img_radio.png');
				$("#bm_qi").removeAttr("disabled");
		      	$("#bm_zui").removeAttr("disabled");
				$('.x_radio_pic5').prop('src', '<%=path%>/images/marketing/img_radio_n.png');
				$("#bm_tian").attr("disabled","disabled");
				$('#bm_qi').val(formatDateTimeYMD(data.startTime));
				$('#bm_zui').val(formatDateTimeYMD(data.endTime));
				validityTag3=false;
				validityTag1=false;
				validityTag2=true;
			}else{
				$("#bm_tian").removeAttr("disabled");
		        $('.x_radio_pic6').prop('src', '<%=path%>/images/marketing/img_radio_n.png');
		        $("#bm_qi").attr("disabled","disabled");
		     	$("#bm_zui").attr("disabled","disabled");
		     	$('.x_radio_pic5').prop('src', '<%=path%>/images/marketing/img_radio_n.png');
				$("#bm_tian").attr("disabled","disabled");
		     	$(".x_radio_pic7").prop('src', '<%=path%>/images/marketing/img_radio.png');
				validityTag3=true;
				validityTag1=false;
				validityTag2=false;
			}
			
			if(StringEmpty($('#bm_ling').val())&&$('#bm_ling').val()!="1000000"){
				$('.s_fk_pic12').attr('src', '<%=path%>/images/marketing/s_check.png');
	            $(this).find('img').attr('_id', '23');
	            $("#bm_ling").removeAttr("disabled");
	            couponNumTag=true;
			}
			if($("#bm_ting").val()!=null&&$("#bm_ting").val()!=0){
				$('.s_fk_pic13').attr('src', '<%=path%>/images/marketing/s_check.png');
	            $(this).find('img').attr('_id', '25');
	            $("#bm_ting").removeAttr("disabled");
	            expire_chose_Tag=true;
			}
			
			sysBack();
			
		}

		function getQueryString(name) {
			var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
			var r = window.location.search.substr(1).match(reg);
			if (r != null)
				return unescape(r[2]);
			return null;
		}

		//判断字符串是否为空
		function StringEmpty(content) {
			if (content == undefined || content == "" || content == null) {
				return false;
			} else {
				return true;
			}
		}
		//判断是否为数字
		function isNumber(value) {
               var patrn = /^(-)?\d+(\.\d+)?$/;
               if (patrn.exec(value) == null || value == "") {
                   return false
               } else {
                   return true
               }
        }
		
		
		function timeStamp2String (time){
	        var datetime = new Date();
	         datetime.setTime(time);
	         var year = datetime.getFullYear();
	         var month = datetime.getMonth() + 1;
	         var date = datetime.getDate();
	    
	         var mseconds = datetime.getMilliseconds();
	         return year + "-" + month + "-" + date ;
	    };
	    
	    
	    function fileloadon() {
	    	var flag=false;
	        $("#share_image").submit(function () {  
	        	if(flag){
	        		return ;
	        	}
	        	flag=true;
	            $("#share_image").ajaxSubmit({
	                type: "post",
	                url: "${pageContext.request.contextPath}/api/uploadfile/file",
	                data:{"typename":"filepath"},
	                success: function (data1) {
	                	share_pic=data1.realSavePath;
	                	$("#share_pic").attr('src',share_pic);
	                	$("#ep_pic").prop('src',share_pic);
	                },
	                error: function (msg) {
	                    errorDialog("文件上传失败");    
	                }
	            });
	            return false;
	        });
	        $("#share_image").submit();
	    }
	    
	    
	    function intentShare(){
	    	if(tag=="defined_pic"){
     		   window.location.href ="<%=path%>/view/ui/photoPreview?type=0&activity_id="+activity_id;
     	   }else{
     		   window.location.href = "<%=path%>/view/ui/activityPreview?type=0&activity_id="+activity_id;

     	   }  
	    }
	    
	    function sysBack(){
	    	pushHistory();
	 		  window.addEventListener("popstate", function(e) {
	 			 if(tag=="defined_text"){
	 				window.location.href = "<%=path%>/view/ui/createActivitySuccessPage?activityId="+activity_id+"&type=edit";
	 	       	}else if(tag=="defined_pic"){
	 	          	window.location.href = "<%=path%>/view/ui/createActivitySuccessPage?activityId="+activity_id+"&type=edit";
	 	       	}else{
	 	       		window.location.href = "<%=path%>/view/ui/createActivity2?type=edit&&activity_id="+activity_id;
	 	       	}
	 		  }, false);
	    }
	    //后退
	    function pushHistory() {
			  var state = {
			  title: "title",
			  url: "#"
			  };
			  window.history.pushState(state, "title", "#");
		}
	</script>
   <script type="text/javascript">
	
</script>
   
</body>
</html>